package com.education.platform.management.service.impl;

import com.education.platform.common.exception.BusinessException;
import com.education.platform.dao.entity.AppTabDO;
import com.education.platform.management.config.ThreadUser;
import org.springframework.beans.factory.annotation.Autowired;
import com.education.platform.common.service.impl.BaseServiceImpl;
import com.education.platform.dao.AppTabDao;
import org.springframework.stereotype.Service;
import com.education.platform.management.service.AppTabService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;

/**
* describe: app的tab栏和广告栏
* @author : 
* @date: 2020-08-15 09:30:03.604
**/
@Service
public class AppTabServiceImpl extends BaseServiceImpl<AppTabDao,AppTabDO> implements AppTabService {

	private static final Logger LOGGER = LoggerFactory.getLogger(AppTabServiceImpl.class);

    @Autowired
	private AppTabDao appTabDao;


    /**
     * 保存
     *
     * @param entity
     */
    @Override
    public Boolean save(AppTabDO entity) {
        if(entity == null){
            throw new BusinessException("数据为空");
        }
        if(entity.getId()==null){
            entity.setCreateBy(ThreadUser.getUserName());
            entity.setCreateTime(new Date());
            entity.setDeleted(false);
            entity.setStatus(true);
            return appTabDao.insert(entity)==1;
        }else{
            entity.setUpdateBy(ThreadUser.getUserName());
            entity.setUpdateTime(new Date());
            return appTabDao.updateById(entity)==1;
        }
    }
}
